package licode.unisop.client.config;

import licode.unisop.client.service.filter.SopAuthorizationHandler;
import licode.unisop.client.service.filter.SopAuthorizationInterceptor;
import org.checkerframework.checker.units.qual.C;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * 自动配置类
 *
 * @author licode
 */
@Component
@ConditionalOnMissingBean(value = {SopInterceptorConfig.class})
public class SopFilterAutoConfig implements WebMvcConfigurer {
    @Lazy
    @Resource
    private SopAuthorizationHandler sopAuthorizationHandler;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new SopAuthorizationInterceptor(sopAuthorizationHandler))
                .addPathPatterns("/**");
    }
}
